cmake_minimum_required(VERSION 3.5.1)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(tools ${CMAKE_CURRENT_SOURCE_DIR}/toolchain/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu)
set(CMAKE_C_COMPILER ${tools}/bin/aarch64-none-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/aarch64-none-linux-gnu-g++)

project(ffmpeg_rkmpp_drm)

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_CXX_FLAGS "-O0 -g")

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)

include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/3rd/install/libdrm/include
	${CMAKE_CURRENT_SOURCE_DIR}/3rd/install/libdrm/include/libdrm
	${CMAKE_CURRENT_SOURCE_DIR}/3rd/install/mpp/include
	${CMAKE_CURRENT_SOURCE_DIR}/3rd/install/opencv/include/opencv4
	${CMAKE_CURRENT_SOURCE_DIR}/3rd/install/ffmpeg/include
	${CMAKE_CURRENT_SOURCE_DIR}/source
)

link_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/3rd/install/libdrm/lib
	${CMAKE_CURRENT_SOURCE_DIR}/3rd/install/mpp/lib
	${CMAKE_CURRENT_SOURCE_DIR}/3rd/install/opencv/lib
	${CMAKE_CURRENT_SOURCE_DIR}/3rd/install/ffmpeg/lib
	${CMAKE_CURRENT_SOURCE_DIR}/3rd/install/x264/lib/
)

file(GLOB_RECURSE INCLUDES "source/*.h")
file(GLOB_RECURSE SOURCES "source/*.c" "source/*.cpp")

add_executable(main ${SOURCES} main.cpp ${INCLUDES})

target_link_libraries(
	main
	avcodec
	avdevice
	avfilter
	avformat
	avutil
	postproc
	avdevice
	swresample
	swscale
	rockchip_mpp
	x264
	drm
	pthread
)
